const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
  mode: 'development',
  devtool: 'source-map',
  entry: {
    home: './src/index.js',
    a: './src/a.js',
  },
  output: {
    filename: 'scripts/[name].[chunkhash:5].js',
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      // 以./public/index.htm 为模版 生成 一个新的html文件到dist目录下
      template: './public/index.html',
      filename: 'home.html',
      chunks: ['home'], // 会引用 home 这个 chunks 打包输出 的所有 js文件
    }),

    new HtmlWebpackPlugin({
      template: './public/index.html',
      filename: 'a.html',
      chunks: ['a'],
    }),
  ],
};
